
#ifndef SX_MSS_PREVIEW_RECORDER_H
#define SX_MSS_PREVIEW_RECORDER_H

#include <sxMSS_PreviewKeyFrame.h>
#include <sxMassSpringSimulation.h>
#include <sxAbstractRecorder.h>
#include <sxAbstractRecording.h>
#include <sxMassSpringSimulation.h>

/* Sx Library Types. */
using Sx::Multimedia::AbstractRecorder;
using Sx::Multimedia::AbstractRecording;
using Sx::Simulation::Animation::MSS_PreviewKeyFrame;
using Sx::Simulation::Simulations::MassSpringSimulation;

namespace Sx {
namespace Simulation {
namespace Recording {

typedef AbstractRecording<MSS_PreviewKeyFrame, MSS_PreviewKeyFrame::FrameUnit> MSS_PreviewRecording;

class MSS_PreviewRecorder : public AbstractRecorder<MSS_PreviewKeyFrame, MSS_PreviewKeyFrame::FrameUnit> {
public:
	MSS_PreviewRecorder(const std::shared_ptr<MassSpringSimulation>& simulation, const std::shared_ptr<MSS_PreviewRecording>& recording);
	virtual ~MSS_PreviewRecorder();

	/* Progress the simulation by n steps (dt) and record every m_th frame */
	bool recordSteps(unsigned int n, unsigned int m);

protected:
	std::shared_ptr<MassSpringSimulation> simulation;

	/* How to process a mass-spring simulation frame */
	bool processFrame(MSS_PreviewKeyFrame& frame);
};

}

}

}

#endif
